<HTML><HEAD><TITLE>instance(?Instance, ?Term)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Comparing and Sorting</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>instance(?Instance, ?Term)</H1>
Succeeds if Instance is an instance of Term.


<DL>
<DT><EM>Instance</EM></DT>
<DD>An arbitrary term.
</DD>
<DT><EM>Term</EM></DT>
<DD>An arbitrary term.
</DD>
</DL>
<H2>Description</H2>
   Succeeds if it is possible to find an instantiation of free variables in
   Term such that Term and Instance are equal.  The result is undefined if
   Term and Instance share variables.  Note that no unification actually
   occurs.
<P>
   Attributed variables are handled via the attribute's compare_instances
   handler.  In particular, domain variables should be handled correctly.
<P>

<H3>Modes and Determinism</H3><UL>
<LI>instance(?, ?) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if Instance is not an instance of Term.
<H2>Examples</H2>
<PRE>
   Success:
   instance(atom,X).
   instance(f(a,b),X).
   instance(f(a,b),f(X,Y)).
   instance(f(a,X),f(Y,X)).
   instance(f(a,X),f(X,Y)).
   instance(f(X,Y),f(Y,X)).
   instance([a,b,c],[A,B,C]).
   instance([a,f(1,b,X),Y|Z],T).
   X::1..5, instance(3,X).
   X::2..4, Y::1..5, instance(X,Y).

   Fail:
   instance(f(a,b),f(X,X)).
   instance(X,a).
   X::2..4, Y::1..5, instance(Y,X).
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/termcomp/compare_instances-3.html">compare_instances / 3</A>, <A HREF="../../kernel/termcomp/prune_instances-2.html">prune_instances / 2</A>, <A HREF="../../kernel/termcomp/variant-2.html">variant / 2</A>
</BODY></HTML>
